<template>
  <div class="positionDetail">
    <!-- 我是 positionDetail -->
    <div class="main" v-if="isshow">
      <div class="navbar">
        <van-nav-bar
          left-text="返回"
          right-text="按钮"
          left-arrow
          @click-left="$router.back()"
        >
          <template #left>
            <div class="left">
              <i class="iconfont arrow iconbtn_nav_back"></i>
            </div>
          </template>
          <template #right>
            <div class="right">
              <!-- <van-icon name="star-o" /> -->
              <i class="iconfont icons iconbtn_shoucang_nor"></i>
              <!-- <i class="iconfont iconbtn_share"></i> -->

              <i
                class="iconfont icons iconbtn_share"
                @click="showShare = true"
              ></i>
              <!-- <i class="iconfont iconbtn_share"></i> -->
            </div>
          </template>
        </van-nav-bar>
      </div>
      <!-- 职位的信息 -->
      <div class="position-info">
        <van-cell>
          <template #title>
            <div class="left">
              <h2>{{ list.name }}</h2>
              <div class="middle">
                <span>
                  <i class="iconfont icons iconicon_city"></i>
                  {{ list.city }}
                </span>
                <span>
                  <i class="iconfont icons iconicon_nian"></i>
                  {{ list.experience }}
                </span>
                <span>
                  <i class="iconfont icons iconicon_footbar_gs_nor"></i>
                  {{ list.education }}
                </span>
              </div>
              <div class="youshi">
                <span v-for="(item, index) in list.feature" :key="index">{{
                  item
                }}</span>
              </div>
            </div>
          </template>
          <template #default>
            <span class="xinzi">{{ list.salary }}</span>
          </template>
        </van-cell>
      </div>
      <!-- 职位描述 -->
      <div class="position-miaoshu">
        <div class="title">职位描述</div>
        <div class="info">{{ list.responsibility }}</div>
      </div>
      <!-- 公司的信息 -->
      <div class="business-info">
        <div class="left">
          <img class="pic" :src="baseUrl + list.company.logo" />
        </div>
        <div class="center">
          <div class="title">{{ list.company.name }}</div>
          <div class="center-btm">
            <span>{{ list.company.type }}</span>
            <span>{{ list.company.step }}</span>
            <span>{{ list.company.scale }}</span>
          </div>
        </div>
        <div class="right" @click="$router.go(-2)">
          <van-icon class="arrow" name="arrow" />
        </div>
      </div>
      <!-- 去刷题按钮 -->
      <div class="go-shuati">
        <van-button type="danger" @click="$router.push('/question')"
          >去刷题</van-button
        >
      </div>
      <!-- 分享面板 -->
      <div class="sharepop">
        <van-share-sheet
          v-model="showShare"
          title="立即分享给好友"
          :options="options"
        />
      </div>
    </div>
  </div>
</template>

<script>
import { positionDetail } from '@/api/api.js'
export default {
  data () {
    return {
      showShare: false,
      list: [],
      isshow: false,
      baseUrl: 'https://autumnfish.cn/heimamm_server/',
      options: [
        { name: '微信', icon: 'wechat' },
        { name: '微博', icon: 'weibo' },
        { name: '复制链接', icon: 'link' },
        { name: '分享海报', icon: 'poster' },
        { name: '二维码', icon: 'qrcode' }
      ]
    }
  },
  methods: {
    async getDate () {
      this.isshow = false
      const res = await positionDetail(this.$route.params.id)
      console.log(res.data)
      this.list = res.data.data
      if (res.data.data.length !== 0) {
        this.isshow = true
      }
    }
  },
  created () {
    this.$nextTick(() => {
      this.getDate()
    })
  }
}
</script>

<style lang="less" scoped>
.positionDetail {
  margin-bottom: 100px;
  // margin-top: 50px;
  .navbar {
    // position: fixed;
    // top: 0;
    // left: 0;
    // background-color: #ffffff;
    // // z-index: 100;
    .left {
      // padding-left: 15px;
      // margin-left: 0px;
      .arrow {
        font-size: 40px;
      }
    }
    .right {
      .icons {
        font-size: 30px;
        margin-left: 10px;
        color: #464646;
      }
      .icons:last-child {
        font-size: 26px;
      }
    }
  }
  .position-info {
    margin-top: 15px;
    .left {
      .middle {
        margin-top: 15px;
        span {
          margin-right: 10px;
          .icons {
            color: #b4b4bc;
            font-size: 16px;
          }
        }
      }
      .youshi {
        margin-top: 8px;
        span {
          color: #b4b4bd;
          padding-right: 5px;
          font-size: 12px;
        }
      }
    }
    /deep/ .van-cell__title {
      flex: 9;
    }
    /deep/ .van-cell__value {
      flex: 3;
    }
    .xinzi {
      color: red;
    }
  }
  .position-miaoshu {
    padding: 0 15px;
    margin-top: 30px;
    .title {
      font-size: 20px;
    }
    .info {
      margin-top: 15px;
      font-size: 16px;
    }
  }
  .business-info {
    display: flex;
    margin-top: 30px;
    height: 100px;
    .left {
      flex: 2;
      padding: 3px 15px;
      .pic {
        width: 100%;
        height: 50px;
      }
    }
    .center {
      flex: 9;
      font-size: 16px;
      padding-left: 7px;
      padding-top: 5px;
      .center-btm {
        margin-top: 10px;
        span {
          font-size: 14px;
          padding: 2px 5px;
          border: 1px solid #d4d4d9;
          color: #545671;
          margin-right: 6px;
        }
      }
    }
    .right {
      flex: 1;
      position: relative;
      .arrow {
        font-size: 25px;
        position: absolute;
        top: 15px;
        right: 0;
      }
    }
  }
  .go-shuati {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background: #ffffff;
    text-align: center;
    padding-top: 20px;
    padding: 20px 15px;
    /deep/ .van-button--danger {
      width: 100%;
      border-radius: 10px;
    }
  }
}
</style>
